<template>
  <div>
    <input @blur="flag = !flag" v-if="flag" ref="input1" type="text" />
    <button @click="btn" v-else>我是按钮</button>
  </div>
</template>
<script>
export default {
  name: '',
  data () {
    return {
      flag: false
    }
  },
  created () {
  },
  computed: {
  },
  methods: {
    btn () {
      this.flag = true
    }
  },
  mounted () {

  },
  updated () {
    if (this.$refs.input1) {
      this.$refs.input1.value = '我是文本框'
      this.$refs.input1.focus()
    }

  }
}
</script>
<style lang='less'  scoped>
</style>
